home *** CD-ROM | disk | FTP | other *** search
Wrap
// Copyright (c) 2006 Nero AG and its licensors. // All rights reserved. //////////////////////////// COMMON DESCRIPTIONS ////////////////////////// // // This script consists of several modules, that correspond to a part of the // functionality. The modules encapsulate their functions, please consider // adding new functions to the corresponding module. // // Module list: // 1) Nero translation for scripts // The translation of the script is done during translation of the html // page. So I think you'll have nothing to do with this part. // 2) Animation module // This module displays the background animations, e.g. burning, // verifying, ripping etc. // 3) Status handling module // This module changes the animation, buttons and other components // depending on current status changes, depending on the values, coming // from the gadget COM server // 4) The slider module // This module handles the flyouts and dialogs (that are shown inside // the fly-out) // 5) The common button module // This module contains common functions for buttons // 6) The main button module // Specific funtions for the main button (copy/cancel) // 7) The increment copies button module // Specific funtions for the increment copies button // 8) The decrement copies button module // Specific functions for the decrement copies button // 9) Digits Module // Common functions for showing the digits inside the display // 10) Display module // This module contains specific functions to update the display // (the percentage, copies number etc) // 11) The COM server Module // This module wraps the COM server, which provides the core // funtionality of the gadget (the burning itself) // 12) Initialization module // Contains functions related to the startup of the gadget // // // Authors: // ------------------------- // Alexander Hofmann // Hans Werner // Vitalij Polovinkin // ... // Person in charge: Alexander Hofmann // Product Management: Alexander Gold var PersistentFileName; ////////////////////////////// translation module ////////////////////////////////// function RemoveLanguageTags(s) { return s.replace("#L_#","").replace("#_L#",""); } ////////////////////////////// amimation module //////////////////////////////////// /// This method loads frames of an animation into an array and returns it. /// @param Dir The relative directory of the animation /// @param Prefix The prefix of the file name /// @param Extension The Extension of the frames in the animation /// @param Count The number of Pictures in the animation /// @return an array with frames of the animation function SetupAnimation(Dir,Prefix,Extension,Count) { var v = new Array(); for (i=1;i<=Count;i++) v[i-1] = "images/" + Dir + Prefix + ((i<10)?"0":"")+ i + Extension; return v; }; /// Showing that a writable disc is present var WritableDiscAnimation = SetupAnimation("","NDCG_main_opt_actual_Idle _writeable disc_ ",".png",1); /// Showing that a readonly disc is present var ReadOnlyDiscAnimation = SetupAnimation("","NDCG_main_opt_actual_Idle _read-only disc_ ",".png",1); /// showing that no discs present var NoDiscAnimation = SetupAnimation("","NDCG_main_opt_actual_Idle _no disc_ ",".png",1); /// the ripping animation var RippingAnimation = SetupAnimation("Ripping/","NDCG_main_opt_actual_",".png",30); /// finalizing disc var FinalizingAnimation = SetupAnimation("Finalizing/","NDCG_main_opt_actual_",".png",30); /// verifying var VerifyingAnimation = SetupAnimation("Importing - Reading - Preparing - Verifying/","NDCG_main_opt_actual_",".png",30); /// the burning animations (red) var BurningAnimation = new Array(); BurningAnimation[0]=SetupAnimation("Burning 01-10/","NDCG_main_opt_actual_",".png",30); BurningAnimation[1]=SetupAnimation("Burning 11-20/","NDCG_main_opt_actual_",".png",30); BurningAnimation[2]=SetupAnimation("Burning 21-30/","NDCG_main_opt_actual_",".png",30); BurningAnimation[3]=SetupAnimation("Burning 31-40/","NDCG_main_opt_actual_",".png",30); BurningAnimation[4]=SetupAnimation("Burning 41-50/","NDCG_main_opt_actual_",".png",30); BurningAnimation[5]=SetupAnimation("Burning 51-60/","NDCG_main_opt_actual_",".png",30); BurningAnimation[6]=SetupAnimation("Burning 61-70/","NDCG_main_opt_actual_",".png",30); BurningAnimation[7]=SetupAnimation("Burning 71-80/","NDCG_main_opt_actual_",".png",30); BurningAnimation[8]=SetupAnimation("Burning 81-90/","NDCG_main_opt_actual_",".png",30); BurningAnimation[9]=SetupAnimation("Burning 91-100/","NDCG_main_opt_actual_",".png",30); BurningAnimation[10]=FinalizingAnimation; /// finalizing disc var FinalizingAnimationBlue = SetupAnimation("Blue Finalizing/","NDCG_main_opt_actual_",".png",30); /// the burning animations (blue) var BurningAnimationBlue = new Array(); BurningAnimationBlue[0]=SetupAnimation("Blue Burning 01-10/","NDCG_main_opt_actual_",".png",30); BurningAnimationBlue[1]=SetupAnimation("Blue Burning 11-20/","NDCG_main_opt_actual_",".png",30); BurningAnimationBlue[2]=SetupAnimation("Blue Burning 21-30/","NDCG_main_opt_actual_",".png",30); BurningAnimationBlue[3]=SetupAnimation("Blue Burning 31-40/","NDCG_main_opt_actual_",".png",30); BurningAnimationBlue[4]=SetupAnimation("Blue Burning 41-50/","NDCG_main_opt_actual_",".png",30); BurningAnimationBlue[5]=SetupAnimation("Blue Burning 51-60/","NDCG_main_opt_actual_",".png",30); BurningAnimationBlue[6]=SetupAnimation("Blue Burning 61-70/","NDCG_main_opt_actual_",".png",30); BurningAnimationBlue[7]=SetupAnimation("Blue Burning 71-80/","NDCG_main_opt_actual_",".png",30); BurningAnimationBlue[8]=SetupAnimation("Blue Burning 81-90/","NDCG_main_opt_actual_",".png",30); BurningAnimationBlue[9]=SetupAnimation("Blue Burning 91-100/","NDCG_main_opt_actual_",".png",30); BurningAnimationBlue[10]=FinalizingAnimationBlue; /// this animation is shown on disc erase var ErasingAnimation = new Array(); for (i=0;i<30;++i) ErasingAnimation[i]=BurningAnimation[(i - i%3)/3][i]; for (i=0;i<29;++i) ErasingAnimation[58-i]=BurningAnimation[(i - i%3)/3][i]; /// current animation frame index var CurrentAnimationFrame = 0; /// current animation var CurrentAnimationLoop = RippingAnimation; /// what should be executed when the animation is going to the end and starting from the beginning var CurrentAnimationRestart = ""; /// is the animation running var bRunning = false; /// the com server, implementing the burning functionality var COMServer = null; /// returns a working COM Server (for the case the server accidently died) function SafeCOMServer() { // first check, if there was a COM server at all. if (COMServer == null) return null; try { COMServer.GetShowAnimations(); } catch(e) { // if there is an error we assume that COM Server died. COMServer = null; reset(); }; return COMServer; } /// main function for showing animations /// @param bRepeat true, if the animation should be repeated function animation(bRepeat) { // should we continue the animation var bContinue = bRepeat; if (CurrentAnimationFrame>=CurrentAnimationLoop.length) CurrentAnimationFrame=0; else bContinue = true; if ((SafeCOMServer()==null) || (!SafeCOMServer().GetShowAnimations())) { CurrentAnimationFrame = 0; bContinue = false; } // change the image source System.Gadget.background = "url(" + CurrentAnimationLoop[CurrentAnimationFrame++] + ")"; // set timeout for further actions if (bContinue && (CurrentAnimationLoop.length > 1)) { bRunning=true; setTimeout( "animation("+bRepeat+")", 100 ); if (CurrentAnimationFrame>=CurrentAnimationLoop.length) setTimeout( CurrentAnimationRestart,1); } else { bRunning=false; } }; ////////////////////////////////// status handling module //////////////////////////////// /// we are in burn process var bBurning = false; /// we were in burn process var bLastBurning = false; /// the burn progress in procent var iProgressPercent = 0; /// we are we in ripping var bRipping = false; /// we were we in ripping var bLastRipping = false; /// do we have a disc in the destination drive var bDiscPresent = false; /// is the disc in the destination drive writable var bWritableDisc = false; /// didi we have a disc in the destination drive var bLastDiscPresent = false; /// was the disc in the destination drive writable var bLastWritableDisc = false; /// are we in verifying var bReading = false; /// were we in verifying var bLastVerifying = false; /// are we in idle state var bIdle = true; /// updating status of the process. changes animations according to current variables function UpdateStatus() { setTimeout("UpdateStatus()",500); COMServerTimer(); /// let's decide which animation we want to show if (bBurning && !bModalDialog) // burning animations { // first set restart if (SafeCOMServer().IsBurningBluRay()) CurrentAnimationRestart="CurrentAnimationLoop=BurningAnimationBlue["+((iProgressPercent-iProgressPercent%10)/10)+"];CurrentAnimationRestart=\"\";"; else CurrentAnimationRestart="CurrentAnimationLoop=BurningAnimation["+((iProgressPercent-iProgressPercent%10)/10)+"];CurrentAnimationRestart=\"\";"; // afterwards if the last animation ended - start a new one. if (!bRunning) { if (SafeCOMServer().IsBurningBluRay()) CurrentAnimationLoop=BurningAnimationBlue[(iProgressPercent-iProgressPercent%10)/10]; else CurrentAnimationLoop=BurningAnimation[(iProgressPercent-iProgressPercent%10)/10]; CurrentAnimationRestart=""; animation(true); } } else if (bRipping && !bModalDialog) // ripping animation { // first set restart CurrentAnimationRestart="CurrentAnimationLoop=RippingAnimation;CurrentAnimationRestart=\"\";"; // afterwards if the last animation ended - start a new one. if (!bRunning) { CurrentAnimationLoop=RippingAnimation; CurrentAnimationRestart=""; animation(true); } } else if (bReading && !bModalDialog) // verification animation { // first set restart CurrentAnimationRestart="CurrentAnimationLoop=VerifyingAnimation;CurrentAnimationRestart=\"\";"; // afterwards if the last animation ended - start a new one. if (!bRunning) { CurrentAnimationLoop=VerifyingAnimation; CurrentAnimationRestart=""; animation(true); } } else if (bWritableDisc) // no further animations present, just stills { if (!bLastWritableDisc) AddMessage(RemoveLanguageTags(L_BurnanbleDisc)); // first set restart //CurrentAnimationRestart="CurrentAnimationLoop=WritableDiscAnimation;CurrentAnimationRestart=\"\";"; CurrentAnimationLoop=WritableDiscAnimation;CurrentAnimationRestart=""; // afterwards if the last animation ended - start a new one. if (!bRunning) { CurrentAnimationLoop=WritableDiscAnimation; CurrentAnimationRestart=""; animation(false); //after the end of the animation don't repeat it from the start } } else if (bDiscPresent) { if (!bLastDiscPresent) AddMessage(RemoveLanguageTags(L_ReadonlyDisc)); // first set restart //CurrentAnimationRestart="CurrentAnimationLoop=ReadOnlyDiscAnimation;CurrentAnimationRestart=\"\";"; CurrentAnimationLoop=ReadOnlyDiscAnimation;CurrentAnimationRestart=""; // afterwards if the last animation ended - start a new one. if (!bRunning) { CurrentAnimationLoop=ReadOnlyDiscAnimation; CurrentAnimationRestart=""; animation(false); //after the end of the animation don't repeat it from the start } } else { if (bLastDiscPresent) AddMessage(RemoveLanguageTags(L_NoDisc)); // first set restart CurrentAnimationRestart="CurrentAnimationLoop=NoDiscAnimation;CurrentAnimationRestart=\"\";"; // afterwards if the last animation ended - start a new one. if (!bRunning) { CurrentAnimationLoop=NoDiscAnimation; CurrentAnimationRestart=""; animation(false); //after the end of the animation don't repeat it from the start }; }; bLastWritableDisc = bWritableDisc; bLastDiscPresent = bDiscPresent; bLastBurning = bBurning; bLastVerifying = bReading; bLastRipping = bRipping; bIdle=!bRipping && !bReading && !bBurning; // update also the main button UpdateMainButton(); // and the display UpdateDisplay(); }; ///////////////////////////// The deatils slider module /////////////////////////////// /// current slide animation var slideAnimation = 1; /// current stretch width of the slideout area var stretchWidth = 5; /// delta-x for slide-out animation var delta = 5; /// is there a modal dialog present? var bModalDialog = false; /// the index of the current message var iMessageIndex = 0; /// first (earliest) message in the buffer var Messages = new Array(); /// The modal dialog (header, bold) var DialogHeading=""; /// The modal dialog message var DialogMessage=""; /// current status text (for checking, if it was already shown in a message) var strCurrentStatusText=""; /// current index of the request to show the slide out var iAppearanceIndex=0; /// current index of the request to hide the slide out var iHidingIndex = 0; /// shows details (in the flyout area) function ShowDetails() { ++iAppearanceIndex; if (!System.Gadget.Flyout.show) System.Gadget.Flyout.show = true; }; /// hides details (in the flyout area) function HideDetails() { if (System.Gadget.Flyout.show) System.Gadget.Flyout.show = false; ++iHidingIndex; }; /// setups the flyout animation to slide in, if current message is equal /// @param index the index of the message to compare with function ConditionalSlideIn(index) { if ((iMessageIndex==index)&&(!bModalDialog)) HideDetails(); }; /// setups the flyout animation to slide in, if current message is equal /// @param index the AppearanceIndex to compare with function ConditionalSlideIn2(index) { if ((iAppearanceIndex==index)&&(!bModalDialog)) HideDetails(); }; /// calls slidein after a period of time function DelaySlideIn() { ++iHidingIndex; setTimeout('HideDetails()', 2500); }; /// slides in if there was nobody else calling SlideOut afterwards; function AutoSlideIn() { ++iHidingIndex; setTimeout("ConditionalSlideIn2("+iAppearanceIndex+")", 2500); } /// calls slideout after a period of time function DelaySlideOut() { ++iAppearanceIndex; setTimeout('ShowDetails()', 180); }; /// setups the flyout animation to slide out, if current message is equal /// @param index the HidingIndex of to compare with function ConditionalSlideOut(index) { if ((iHidingIndex==index)||(bModalDialog)) ShowDetails(); } // slides out if there was nobody calling slidein afterwards; function AutoSlideOut() { ++iAppearanceIndex; if (bModalDialog) setTimeout("ConditionalSlideOut("+iHidingIndex+")", 500); else setTimeout("ConditionalSlideOut("+iHidingIndex+")", 2000); } /// shows last log messages function ShowMessages() { try { OnShowMessages(); } catch (e) { /* ignore */ }; System.Gadget.Flyout.onShow = OnShowMessages; ShowDetails(); }; /// this is called when the flyout is shown with messages function OnShowMessages() { if (!System.Gadget.Flyout.show || bModalDialog) return; LastDialogText = ""; var text = '<table border="0" width="80%">\r\n'; var i; for (i=Messages.length-1;i>=0;--i) { text = text + '<tr style="cursor:default; font-size: 12px;"><td><font color="black"><b>' + (iMessageIndex-Messages.length+1+i) + ". "+ Messages[i] + "</b></font></td></tr>\r\n"; }; text = text + "</table>"; System.Gadget.Flyout.document.getElementById("Log").innerHTML = text; SetupFlyoutCallbacks(); } /// this is called when the flyout is shown with the initial screen with versions function OnShowVersion() { if (!System.Gadget.Flyout.show || bModalDialog) return; System.Gadget.Flyout.document.getElementById("Version").innerHTML = RemoveLanguageTags(L_Version) + " " + System.Gadget.version + "<br />" + RemoveLanguageTags(L_VersionServer) + " " + SafeCOMServer().GetServerVersion(0) + "." + SafeCOMServer().GetServerVersion(1) + "." + SafeCOMServer().GetServerVersion(2) + "." + SafeCOMServer().GetServerVersion(3) + "<br />" + RemoveLanguageTags(L_VersionAPI) + " " + SafeCOMServer().GetNeroAPIVersion(0) + "." + SafeCOMServer().GetNeroAPIVersion(1) + "." + SafeCOMServer().GetNeroAPIVersion(2) + "." + SafeCOMServer().GetNeroAPIVersion(3) + "<br />"; SetupFlyoutCallbacks(); } /// sets callbacks for the flyout elements so the flyout doesn't disappear too quickly function SetupFlyoutCallbacks() { var i; for (i=0;i<System.Gadget.Flyout.document.all.length;++i) { if (System.Gadget.Flyout.document.all[i].onmouseover == null) System.Gadget.Flyout.document.all[i].onmouseover = AutoSlideOut; if (System.Gadget.Flyout.document.all[i].onmouseout == null) System.Gadget.Flyout.document.all[i].onmouseout = AutoSlideIn; }; } /// shows dialog contents function ShowDialog() { bModalDialog=true; try { RefreshDialog(); } catch (e) { /* ignore */ }; System.Gadget.Flyout.onShow = OnShowDialog; ShowDetails(); }; var WAITCD_POPUP_BUTTON_OK = 4; var WAITCD_POPUP_BUTTON_STOP = 8; var WAITCD_POPUP_BUTTON_LOAD = 16; var WAITCD_POPUP_BUTTON_ERASE = 32; var LastDialogText = ""; /// this is called when the flyout is shown with a dialog function RefreshDialog() { var stat = COMServer.GetWaitCDPopupStatus(); var Buttons = (((stat&WAITCD_POPUP_BUTTON_OK)!=0)?'<button onclick="Log.COMServer.SetWaitCDPopupResult('+WAITCD_POPUP_BUTTON_OK+')">'+RemoveLanguageTags(L_Ok)+'</button>':'')+ (((stat&WAITCD_POPUP_BUTTON_LOAD)!=0)?'<button onclick="Log.COMServer.SetWaitCDPopupResult('+WAITCD_POPUP_BUTTON_LOAD+')">'+RemoveLanguageTags(L_CloseTray)+'</button>':'')+ (((stat&WAITCD_POPUP_BUTTON_ERASE)!=0)?'<button onclick="Log.COMServer.SetWaitCDPopupResult('+WAITCD_POPUP_BUTTON_ERASE+')">'+RemoveLanguageTags(L_EraseDisc)+'</button>':'')+ (((stat&WAITCD_POPUP_BUTTON_STOP)!=0)?'<button onclick="Log.COMServer.SetWaitCDPopupResult('+WAITCD_POPUP_BUTTON_STOP+')">'+RemoveLanguageTags(L_Cancel)+'</button>':''); var text = '<b><font color="Black">'+DialogHeading+'</font></b><br/>' + DialogMessage + '<br/>' + Buttons; if (text!=LastDialogText) System.Gadget.Flyout.document.getElementById("Log").innerHTML = text; SetupFlyoutCallbacks(); System.Gadget.Flyout.document.getElementById("Log").COMServer = COMServer; LastDialogText=text; } /// this is called when the flyout is shown with a dialog function OnShowDialog() { LastDialogText=""; RefreshDialog(); } /// adds a message to the log /// @param s the new message function AddMessage(s) { var i; if (iMessageIndex>=100) { for (i = 0; i<99; ++i) Messages[i] = Messages[i+1]; Messages[99] = s; } else Messages[iMessageIndex] = s; iMessageIndex++; if (!bModalDialog) { System.Gadget.Flyout.onShow = OnShowMessages; if ((SafeCOMServer()==null) || (SafeCOMServer().GetVerboseMode() || System.Gadget.Flyout.show)) { ShowMessages(); if (!System.Gadget.Flyout.show) setTimeout("ConditionalSlideIn("+iMessageIndex+")", 5000); }; }; }; /// Clears all Messages function ClearMessages() { iMessageIndex = 0; Messages = new Array(); } /// this function checks if last shown status text should be updated /// in this case it adds a new log message /// @param strText: current status text function CheckCurrentStatusText(strText) { if (strCurrentStatusText!=strText) { strCurrentStatusText=strText; AddMessage(strText); } } //////////////////////// the common button module ///////////////////////// /// the enumeration constant for an idle button var eButtonIdle = 0; /// the enumeration constant for a disabled button var eButtonDisabled = 1; /// the enumeration constant for a pressed button var eButtonPressed = 2; /// the enumeration constant for a hover button var eButtonHover = 3; /// Prepares a button (loads needed images) /// @param strPrefix The Prefix for the location of the button images (e.g. "images/test_") /// @param strPostfix The postfix for the location of the button images (e.g. ".png") function PrepareButton(strPrefix,strSuffix) { var temp=new Array(); temp[eButtonIdle]=new Image(); temp[eButtonIdle].src=strPrefix+"Idle"+strSuffix; temp[eButtonDisabled]=new Image(); temp[eButtonDisabled].src=strPrefix+"Disabled"+strSuffix; temp[eButtonPressed]=new Image(); temp[eButtonPressed].src=strPrefix+"Pressed"+strSuffix; temp[eButtonHover]=new Image(); temp[eButtonHover].src=strPrefix+"Hover"+strSuffix; return temp; }; //////////////////////// the main button module /////////////////////////// /// the images for the copy button var CopyButton = PrepareButton("images/Copy Mode/Copy Button/NDCG_main_opt_actual_",".png"); /// the images for the cancel button var CancelButton = PrepareButton("images/Cancel Mode/Cancel Button/NDCG_main_opt_actual_",".png"); /// is true if the mouse is over the main button var bOverMainButton = false; /// is true if the mouse is pressed var bMainButtonPressed = false; /// current status index var iCurrentMainButtonStatusIndex = 0; /// was the last button the copy button? var bLastCopyButton = true; /// allow pressing the button? this shouldn't always be possible, especially, on button functionality changes var bMainButtonAllowed = true; // conditionally allows the main button function ConditionallyAllowButton(index) { if (iCurrentMainButtonStatusIndex==index) { bMainButtonAllowed = true; UpdateMainButton(); } } /// updates the image on the main button function UpdateMainButton() { var CurrentImageSet; if (bIdle || bModalDialog) { // in this case we want to show the copy button CurrentImageSet=CopyButton; if (bModalDialog) MainButtonImg.alt=RemoveLanguageTags(L_Ok); else MainButtonImg.alt=RemoveLanguageTags(L_Copy); if (!bLastCopyButton) { ++iCurrentMainButtonStatusIndex; bMainButtonAllowed=false; setTimeout("ConditionallyAllowButton("+iCurrentMainButtonStatusIndex+")",3000); bLastCopyButton=true; } } else { // in this case we want to show the cancel button MainButtonImg.alt=RemoveLanguageTags(L_Cancel); CurrentImageSet=CancelButton; if (bLastCopyButton) { ++iCurrentMainButtonStatusIndex; bMainButtonAllowed=false; setTimeout("ConditionallyAllowButton("+iCurrentMainButtonStatusIndex+")",3000); bLastCopyButton=false; } } if (!bMainButtonAllowed || (bIdle && (GetCopies()==0))) MainButtonImg.src = CurrentImageSet[eButtonDisabled].src; else if (bOverMainButton) if (bMainButtonPressed) MainButtonImg.src = CurrentImageSet[eButtonPressed].src; else MainButtonImg.src = CurrentImageSet[eButtonHover].src; else MainButtonImg.src = CurrentImageSet[eButtonIdle].src; }; /// this is called by the framework when the mouse is over the main button function MouseOverMainButton() { bOverMainButton=true; UpdateMainButton(); }; /// this is called by the framework when the mouse is out of the main button function MouseOutOfMainButton() { bOverMainButton=false; UpdateMainButton(); }; /// this is called by the framework when the mouse is pressed on the main button function MainButtonMouseDown() { bMainButtonPressed=true; UpdateMainButton(); }; /// this is called by the framework when the mouse is released on the main button function MainButtonMouseUp() { bMainButtonPressed=false; UpdateMainButton(); }; /// this is called by the framework when the mouse clicked on the main button function MainButtonClicked() { // don't allow the user to click on the button when it just changed if (!bMainButtonAllowed) return; COMServerDebugText( "MainButtonClicked()" ); if (bModalDialog) OnOk(); else if (!bIdle) CancelCopy(); else StartCopy(); }; ////////////////////////// increment copies buttons module /////////////////////////// var bOverIncCopiesButton = false; var bIncCopiesButtonPressed = false; var IncCopiesImageSet = PrepareButton("images/Copy Mode/Copies Plus/NDCG_main_opt_actual_",".png"); var iCurrentCopiesMessageIndex = 0; var iCurrentDelay = 0; var bIncrement = false; function AutoIncrementDecrement(iMessageIndex) { if (iMessageIndex == iCurrentCopiesMessageIndex) { if (iCurrentDelay!=0) { if (bIncrement) { if (GetCopies()<=99) { IncCopies(); UpdateDisplay(); setTimeout("AutoIncrementDecrement("+iMessageIndex+")",iCurrentDelay); } } else { if (GetCopies()>1) { DecCopies(); UpdateDisplay(); setTimeout("AutoIncrementDecrement("+iMessageIndex+")",iCurrentDelay); } } }; } } function StartIncrementDecrement(iMessageIndex,iDelay,bInc) { if (iMessageIndex == iCurrentCopiesMessageIndex) { bIncrement=bInc; if (iCurrentDelay!=0) { iCurrentDelay = iDelay; } else { iCurrentDelay = iDelay; AutoIncrementDecrement(iMessageIndex); } } } /// this is called by the framework when the mouse is over the increment copies button function MouseOverIncCopiesButton() { bOverIncCopiesButton=true; UpdateIncCopiesButton(); iCurrentDelay=0; ++iCurrentCopiesMessageIndex; }; /// this is called by the framework when the mouse is out of the increment copies button function MouseOutOfIncCopiesButton() { bOverIncCopiesButton=false; UpdateIncCopiesButton(); iCurrentDelay=0; ++iCurrentCopiesMessageIndex; }; /// this is called by the framework when the mouse is pressed on the increment copies button function IncCopiesButtonMouseDown() { bIncCopiesButtonPressed=true; UpdateIncCopiesButton(); ++iCurrentCopiesMessageIndex; iCurrentDelay=0; setTimeout("StartIncrementDecrement("+iCurrentCopiesMessageIndex+",500,true)",500); setTimeout("StartIncrementDecrement("+iCurrentCopiesMessageIndex+",250,true)",2000); setTimeout("StartIncrementDecrement("+iCurrentCopiesMessageIndex+",125,true)",4000); }; /// this is called by the framework when the mouse is released on the increment copies button function IncCopiesButtonMouseUp() { bIncCopiesButtonPressed=false; UpdateIncCopiesButton(); ++iCurrentCopiesMessageIndex; }; /// this is called by the framework when the mouse clicked on the increment copies button function IncCopiesButtonClicked() { if (GetCopies()<=99) { IncCopies(); UpdateDisplay(); } iCurrentDelay=0; ++iCurrentCopiesMessageIndex; }; /// updates the image on the main button function UpdateIncCopiesButton() { if (GetCopies()>=99) IncCopiesImg.src = IncCopiesImageSet[eButtonDisabled].src; else if (bOverIncCopiesButton) if (bIncCopiesButtonPressed) IncCopiesImg.src = IncCopiesImageSet[eButtonPressed].src; else IncCopiesImg.src = IncCopiesImageSet[eButtonHover].src; else IncCopiesImg.src = IncCopiesImageSet[eButtonIdle].src; }; ////////////////////////// decrement copies buttons module /////////////////////////// var bOverDecCopiesButton = false; var bDecCopiesButtonPressed = false; var DecCopiesImageSet = PrepareButton("images/Copy Mode/Copies Minus/NDCG_main_opt_actual_",".png"); /// this is called by the framework when the mouse is over the decrement copies button function MouseOverDecCopiesButton() { bOverDecCopiesButton=true; UpdateDecCopiesButton(); ++iCurrentCopiesMessageIndex; iCurrentDelay=0; }; /// this is called by the framework when the mouse is out of the decrement copies button function MouseOutOfDecCopiesButton() { bOverDecCopiesButton=false; UpdateDecCopiesButton(); ++iCurrentCopiesMessageIndex; iCurrentDelay=0; }; /// this is called by the framework when the mouse is pressed on the decrement copies button function DecCopiesButtonMouseDown() { bDecCopiesButtonPressed=true; UpdateDecCopiesButton(); ++iCurrentCopiesMessageIndex; iCurrentDelay=0; setTimeout("StartIncrementDecrement("+iCurrentCopiesMessageIndex+",500,false)",500); setTimeout("StartIncrementDecrement("+iCurrentCopiesMessageIndex+",250,false)",2000); setTimeout("StartIncrementDecrement("+iCurrentCopiesMessageIndex+",125,false)",4000); }; /// this is called by the framework when the mouse is released on the decrement copies button function DecCopiesButtonMouseUp() { bDecCopiesButtonPressed=false; UpdateDecCopiesButton(); iCurrentDelay=0; ++iCurrentCopiesMessageIndex; }; /// this is called by the framework when the mouse clicked on the decrement copies button function DecCopiesButtonClicked() { if (GetCopies()>1) { DecCopies(); UpdateDisplay(); } iCurrentDelay=0; ++iCurrentCopiesMessageIndex; }; /// updates the image on the main button function UpdateDecCopiesButton() { if (GetCopies()<=1) DecCopiesImg.src = DecCopiesImageSet[eButtonDisabled].src; else if (bOverDecCopiesButton) if (bDecCopiesButtonPressed) DecCopiesImg.src = DecCopiesImageSet[eButtonPressed].src; else DecCopiesImg.src = DecCopiesImageSet[eButtonHover].src; else DecCopiesImg.src = DecCopiesImageSet[eButtonIdle].src; }; //////////////////////////////// digits module ///////////////////////////////// /// this function loads the pictures of digits /// @param strPrefix the prefix for the location of the pictures (e.g. "images/Digit_") /// @param strPostfix the postfix for the location of the pictures (e.g. ".png") function PrepareDigits(strPrefix,strPostfix) { var temp = new Array(); var i; for (i = 0; i < 10; ++i) { temp[i] = new Image(); temp[i].src = strPrefix+i+strPostfix; } return temp; }; /// the digits to show var Digits=PrepareDigits("images/digits/Digit_",".PNG"); var BlackDigits=PrepareDigits("images/digits/Digit_","b.PNG"); /// shows digits area /// @param iNullToNinentyNine The two digits to display /// @param bBlack function UpdateDigits(iNullToNinetyNine, bBlack) { var i = iNullToNinetyNine; if (iNullToNinetyNine>99) i=99; if (i<0) i=0; if (bBlack) { LSDigitImg.src=BlackDigits[i%10].src; MSDigitImg.src=BlackDigits[(i-i%10)/10].src; } else { LSDigitImg.src=Digits[i%10].src; MSDigitImg.src=Digits[(i-i%10)/10].src; } }; ////////////////////////// The display module ///////////////////////////////// var CopiesDisplayImage = new Image(); CopiesDisplayImage.src="images/Copy Mode/Copies Entry/NDCG_main_opt_actual_Entry.png"; var PercentDisplayImage = new Image(); PercentDisplayImage.src="images/Copy Mode/Percentage Display/NDCG_main_opt_actual_Display.png"; function UpdateDisplay() { if (bIdle || bModalDialog) { if ((SafeCOMServer() != null) && (SafeCOMServer().GetShowCopies())) { // show number of copies UpdateDecCopiesButton(); UpdateIncCopiesButton(); DisplayImg.src = CopiesDisplayImage.src; LSDigitImg.style.visibility = "visible"; MSDigitImg.style.visibility = "visible"; DisplayImg.style.visibility = "visible"; IncCopiesImg.style.visibility = "visible"; DecCopiesImg.style.visibility = "visible"; LSDigitImg.alt = RemoveLanguageTags(L_NumberOfCopies); MSDigitImg.alt = RemoveLanguageTags(L_NumberOfCopies); DisplayImg.alt = RemoveLanguageTags(L_NumberOfCopies); UpdateDigits(GetCopies(),true); } else { IncCopiesImg.style.visibility = "hidden"; DecCopiesImg.style.visibility = "hidden"; LSDigitImg.style.visibility = "hidden"; MSDigitImg.style.visibility = "hidden"; DisplayImg.style.visibility = "hidden"; } } else { // show current progress DisplayImg.src = PercentDisplayImage.src; LSDigitImg.style.visibility = "visible"; MSDigitImg.style.visibility = "visible"; DisplayImg.style.visibility = "visible"; IncCopiesImg.style.visibility = "hidden"; DecCopiesImg.style.visibility = "hidden"; LSDigitImg.alt = RemoveLanguageTags(L_Progress); MSDigitImg.alt = RemoveLanguageTags(L_Progress); DisplayImg.alt = RemoveLanguageTags(L_Progress); UpdateDigits(iProgressPercent,false); } }; /////////////////////////// com server module /////////////////////////////////// /// the com server, implementing the burning functionality var COMServer = null; /// this is true when the wait for cd dialog is shown var bDialogWaitForCD = false; /// this is true when the popup dialog is shown var bDialogPopup = false; /// this is true if we shown a message, that an error occured var bErrorTextPresent = false; /// the result fo OK button var IDOK = 4; /// The result for the Cancel button var IDCANCEL = 8; /// The result for the LoadTray button var IDLOADTRAY = 16; /// the result for the Erase button var IDERASE = 32; var NERO_PHASE_ABORT = -3; var NERO_PHASE_ERROR = -2; var NERO_PHASE_IDLE = -1; var NERO_PHASE_BURNING_COMPLETE = 0; var NERO_PHASE_BURN_PROCESS_STARTED = 1; var NERO_PHASE_BUILD_IMAGE = 2; var NERO_PHASE_START_CACHE = 24; var NERO_PHASE_DONE_CACHE = 25; var NERO_PHASE_FAIL_CACHE = 26; var NERO_PHASE_ABORT_CACHE = 27; var NERO_PHASE_START_TEST = 28; var NERO_PHASE_DONE_TEST = 29; var NERO_PHASE_FAIL_TEST = 30; var NERO_PHASE_ABORT_TEST = 31; var NERO_PHASE_START_SIMULATE = 32; var NERO_PHASE_DONE_SIMULATE = 33; var NERO_PHASE_FAIL_SIMULATE = 34; var NERO_PHASE_ABORT_SIMULATE = 35; var NERO_PHASE_START_WRITE = 36; var NERO_PHASE_DONE_WRITE = 37; var NERO_PHASE_FAIL_WRITE = 38; var NERO_PHASE_ABORT_WRITE = 39; var NERO_PHASE_START_SIMULATE_NOSPD = 61; var NERO_PHASE_DONE_SIMULATE_NOSPD = 62; var NERO_PHASE_FAIL_SIMULATE_NOSPD = 63; var NERO_PHASE_ABORT_SIMULATE_NOSPD = 64; var NERO_PHASE_START_WRITE_NOSPD = 65; var NERO_PHASE_DONE_WRITE_NOSPD = 66; var NERO_PHASE_FAIL_WRITE_NOSPD = 67; var NERO_PHASE_ABORT_WRITE_NOSPD = 68; var NERO_PHASE_PREPARE_ITEMS = 73; var NERO_PHASE_VERIFY_COMPILATION = 78; var NERO_PHASE_VERIFY_ABORTED = 79; var NERO_PHASE_VERIFY_END_OK = 80; var NERO_PHASE_VERIFY_END_FAIL = 81; var NERO_PHASE_ENCODE_VIDEO = 82; var NERO_PHASE_SEAMLESSLINK_ACTIVATED = 87; var NERO_PHASE_BUP_ACTIVATED = 90; // Generic: Buffer underun protection activated var NERO_PHASE_START_FORMATTING = 98; var NERO_PHASE_CONTINUE_FORMATTING = 99; var NERO_PHASE_FORMATTING_SUCCESSFUL = 100; var NERO_PHASE_FORMATTING_FAILED = 101; var NERO_PHASE_PREPARE_CD = 105; var NERO_PHASE_DONE_PREPARE_CD = 106; var NERO_PHASE_FAIL_PREPARE_CD = 107; var NERO_PHASE_ABORT_PREPARE_CD = 108; var NERO_PHASE_DVDVIDEO_DETECTED = 111; var NERO_PHASE_DVDVIDEO_REALLOC_STARTED = 112; var NERO_PHASE_DVDVIDEO_REALLOC_COMPLETED = 113; var NERO_PHASE_DVDVIDEO_REALLOC_NOTNEEDED = 114; var NERO_PHASE_DVDVIDEO_REALLOC_FAILED = 115; var NERO_PHASE_DRM_CHECK_FAILURE = 169; var NERO_PHASE_START_WRITE_DATAFILES = 171; var NERO_PHASE_DONE_WRITE_DATAFILES = 172; var NERO_PHASE_FAIL_WRITE_DATAFILES = 173; var NERO_PHASE_WARN_WRITE_DATAFILES = 174; var NERO_PHASE_START_BAO_FINALIZE = 175; var NERO_PHASE_FAIL_BAO_FINALIZE = 176; var NERO_PHASE_DONE_BAO_FINALIZE = 177; var NERO_PHASE_FAIL_BAO_PREPARE = 178; var NERO_PHASE_FAIL_BAO_WRITEFILE = 179; var NERO_PHASE_BURN_LAYER_1 = 180; var NERO_PHASE_BURN_LAYER_2 = 181; var comServerState; var comServerBusy; var lastMessageStat = NERO_PHASE_IDLE; /// this method is executed periodically to query the status from /// the com server function COMServerTimer() { // if no server -skip this part if (SafeCOMServer() == null) return; // Notify the server that the gadget is still running // (under some conditions Windows doesn't call onUnload on the gadget document // and the server remains in memory. Now the sevrer closes if the callback is not // called for some time, and we need to notify the server so it doesn't close) SafeCOMServer().KeepAlive(120000); var serverState = SafeCOMServer().GetBurningState(); if( serverState != comServerState ) { comServerState = serverState; COMServerDebugText( "Burning State: "+serverState ); } var serverBusy = ( serverState > 0 ); if( serverBusy != comServerBusy ) { comServerBusy = serverBusy; if( !serverBusy ) { msg = SafeCOMServer().GetErrorMessage(); COMServerDebugText( "Error message: "+msg ); } } var stat = SafeCOMServer().GetWaitCDPopupStatus(); if ( ((stat & 3) == 0 && bDialogWaitForCD) || ((stat & 4) !=0)) { if (bModalDialog) { bModalDialog = false; ShowMessages(); } bDialogWaitForCD = false; } else if ((stat & 3) !=0) { DialogHeading = RemoveLanguageTags(L_WaitCD); DialogMessage = SafeCOMServer().GetWaitCDPopupText(); bDialogWaitForCD = true; if (!bModalDialog) AddMessage(DialogHeading + ' ' + RemoveLanguageTags(L_Dialog)); ShowDialog(); return; }; if( !bModalDialog && SafeCOMServer().IsPopupWaiting() ) { DialogHeading = SafeCOMServer().GetPopupTitle(); DialogMessage = SafeCOMServer().GetPopupText(); AddMessage(DialogHeading); bDialogPopup = true; ShowDialog(); return; } iProgressPercent = SafeCOMServer().GetProgressInPercent(); CheckCurrentStatusText(SafeCOMServer().GetBurningStateText()); stat = serverState; if ((stat == NERO_PHASE_START_CACHE) || (stat == NERO_PHASE_BURN_PROCESS_STARTED) || (stat == NERO_PHASE_VERIFY_COMPILATION) || (stat == NERO_PHASE_BUILD_IMAGE) ) { bReading = true; bBurning = false; if ((lastMessageStat!=stat) && ( stat == NERO_PHASE_BURN_PROCESS_STARTED)) AddMessage(RemoveLanguageTags(L_BurningStarted)); } else if (( stat == NERO_PHASE_START_SIMULATE) || ( stat == NERO_PHASE_START_WRITE) || ( stat == NERO_PHASE_START_SIMULATE_NOSPD) || ( stat == NERO_PHASE_START_WRITE_NOSPD) || ( stat == NERO_PHASE_START_FORMATTING) || ( stat == NERO_PHASE_DVDVIDEO_REALLOC_STARTED) || ( stat == NERO_PHASE_START_WRITE_DATAFILES) || ( stat == NERO_PHASE_START_BAO_FINALIZE) ) { bReading = false; bBurning = true; // show the finalizing animation if (stat == NERO_PHASE_START_BAO_FINALIZE) iProgressPercent = 100; } else if (( stat == NERO_PHASE_PREPARE_ITEMS) || ( stat == NERO_PHASE_PREPARE_CD) || ( stat == NERO_PHASE_IDLE) || ( stat == NERO_PHASE_BURNING_COMPLETE) || ( stat == NERO_PHASE_ABORT) || ( stat == NERO_PHASE_ERROR) ) { iProgressPercent = 0; bReading = false; bBurning = false; if (lastMessageStat!=stat) if ( stat == NERO_PHASE_BURNING_COMPLETE) AddMessage(RemoveLanguageTags(L_BurningComplete)); else if ( stat == NERO_PHASE_ABORT) AddMessage(RemoveLanguageTags(L_BurningAborted)); else if ( stat == NERO_PHASE_ERROR) AddMessage(RemoveLanguageTags(L_BurningError)); else if ( stat == NERO_PHASE_BURN_PROCESS_STARTED) AddMessage(RemoveLanguageTags(L_BurningStarted)); }; lastMessageStat = stat; }; /// this is called when the copy button is clicked function StartCopy() { bErrorTextPresent = false; if( SafeCOMServer() != null ) { ClearMessages(); SafeCOMServer().StartBurn( true ); } }; /// this is called when the cancel button is clicked function CancelCopy() { if( SafeCOMServer() != null ) { AddMessage(RemoveLanguageTags(L_UserAborted)); SafeCOMServer().StartBurn( false ); } }; /// increment the number of copies function IncCopies() { if (SafeCOMServer() == null) return; SafeCOMServer().SetNumberOfCopies( SafeCOMServer().GetNumberOfCopies() +1 ); }; /// decrement the number of copies function DecCopies() { if (SafeCOMServer() == null) return; SafeCOMServer().SetNumberOfCopies( SafeCOMServer().GetNumberOfCopies() -1 ); }; /// returns the number of copies function GetCopies() { if (SafeCOMServer() == null) return 0; return SafeCOMServer().GetNumberOfCopies()-((SafeCOMServer().GetNumberOfActualCopy()<=0)?0:(SafeCOMServer().GetNumberOfActualCopy()-1)); }; function OnOk() { ShowDetails(); if( bDialogWaitForCD ) SafeCOMServer().SetWaitCDPopupResult(WAITCD_POPUP_BUTTON_OK|WAITCD_POPUP_BUTTON_LOAD|WAITCD_POPUP_BUTTON_ERASE); if( bDialogPopup ) SafeCOMServer().SetPopupResult( IDOK ); }; function OnCancel() { ShowDetails(); AddMessage(RemoveLanguageTags(L_UserAborted)); if( bDialogWaitForCD ) SafeCOMServer().SetWaitCDPopupResult( WAITCD_POPUP_BUTTON_STOP ); if( bDialogPopup ) SafeCOMServer().SetPopupResult( IDCANCEL ); }; function COMServerInitialize() { if ( COMServer == null) { try { COMServer = new ActiveXObject( "NeroGadgetCMServer.NeroGadgetCM" ); // Nero Gadget COM Server } catch(e) { // ignore errors }; } // if there is still no COM Server - stop if( COMServer == null ) return; //comServer.BurnImageFile("D:\\TestDisk.iso"); var i = SafeCOMServer().GetSelectedReaderDrive(); var msg = "Reader drive: "; if( i < 0 ) msg += "not found."; else msg += SafeCOMServer().GetReaderDriveName( i ); COMServerDebugText( msg ); i = SafeCOMServer().GetSelectedBurnDrive(); var msg = "Burner drive: "; if( i < 0 ) msg += "not found."; else msg += SafeCOMServer().GetBurnDriveName( i ); COMServerDebugText( msg ); COMServerTimer(); } /// prints a debug text in the output window of a native debugger /// @text: the text to show function COMServerDebugText( text ) { if( SafeCOMServer() != null ) { SafeCOMServer().OutputDebugText( text ); } } //////////////////////////////// init //////////////////////////////////////// /// this is called when user rolls the mouse wheel. function OnWheel(event) { if (!event) event = window.event; var delta = 0; if (event.wheelDelta) delta = event.wheelDelta; if (delta) { if (delta<0) DecCopiesButtonClicked(); else IncCopiesButtonClicked(); } } /// this is called to re-read the settings function SettingsChanged() { SafeCOMServer().LoadPersistency(PersistentFileName); UpdateDisplay(); } /// this is called when the user closed the settings function SettingsClosed(event) { if (event.closeAction == event.Action.commit) SettingsChanged(); } /// this function is called when user drops some items into the gadget function OnItemsDropped() { var item = System.Shell.itemFromFileDrop(event.dataTransfer, 0); var item2 = System.Shell.itemFromFileDrop(event.dataTransfer, 1); if (item == null) { AddMessage(RemoveLanguageTags(L_DropError)); ShowDetails(); } else if (item2 != null) { AddMessage(RemoveLanguageTags(L_DropErrorMultipleFiles)); showDetails(); } else if (item.isLink) { AddMessage(RemoveLanguageTags(L_DropErrorLink)); showDetails(); } else if (item.isFolder) { AddMessage(RemoveLanguageTags(L_DropErrorFolder)); showDetails(); } else if (SafeCOMServer().GetBurningState()>=NERO_PHASE_BURN_PROCESS_STARTED) { AddMessage(RemoveLanguageTags(L_DropErrorAlreadyBurning)); showDetails(); } else { ClearMessages(); AddMessage(RemoveLanguageTags(L_DropBurningStarted)); SafeCOMServer().BurnImageFile(item.path); } } function OnDragEnter() { event.returnValue = false; } function OnDragOver() { event.returnValue = false; } function reset() { HideDetails(); UpdateStatus(); DisplayImg.onmousewheel = LSDigitImg.onmousewheel= MSDigitImg.onmousewheel= MainButtonImg.onmousewheel= IncCopiesImg.onmousewheel= DecCopiesImg.onmousewheel = OnWheel; var i; for (i=0;i<document.all.length;++i) { if (document.all[i].onmouseover == null) document.all[i].onmouseover = AutoSlideOut; if (document.all[i].onclick == null) document.all[i].onclick = ShowDetails; if (document.all[i].onmouseout == null) document.all[i].onmouseout = AutoSlideIn; if (document.all[i].ondragenter == null) document.all[i].ondragenter = OnDragEnter; if (document.all[i].ondragover == null) document.all[i].ondragover = OnDragOver; } setTimeout("DelaySlideOut()",1); setTimeout("HideDetails()",5000); // init flyout before setting up com server // so we can dispplay messages System.Gadget.Flyout.file = "flyout.html"; System.Gadget.Flyout.show = true; COMServerInitialize(); if( COMServer == null ) // COM server creation error { AddMessage("COM Server not found."); AddMessage("Critical Error"); return; }; // show versions only when server initialized System.Gadget.Flyout.onShow = OnShowVersion; // allow settings only if com server is present // so init them after setup of the com server System.Gadget.settingsUI = "settings.html"; System.Gadget.onSettingsClosed = SettingsClosed; PersistentFileName = System.Gadget.Settings.read("PersistentFileName"); if (PersistentFileName == "") { PersistentFileName = SafeCOMServer().GeneratePersistencyFileName(); System.Gadget.Settings.write("PersistentFileName", PersistentFileName); SafeCOMServer().SavePersistency(PersistentFileName); } else SafeCOMServer().LoadPersistency(PersistentFileName); UpdateStatus(); };